package com.lmpop.updateHtml.updateHtml;

import com.lmpop.trade.ts_module.Ts_moduleInfo;
import com.lmpop.updateHtml.parseHtml.UpdateHtml;
import java.util.Hashtable;
import java.util.List;

public class UpdateArticleHtml
{
  public UpdateHtml updateHtml;

  public UpdateArticleHtml()
  {
    this.updateHtml = new UpdateHtml();
  }

  public static void main(String[] args)
  {
    UpdateArticleHtml uah = new UpdateArticleHtml();
    uah.updateArticleByGoodsId("7212356b1j38456", "0N7x1VP8CYF7W44", "0", "1");
  }

  public void updateArticle(String model, String article_temp, String save_dir, Hashtable paramMap)
  {
    this.updateHtml.updateArticle(model, article_temp, save_dir, paramMap);
  }

  public void updateArticleByCh(String module_id, String start, String row) {
    Ts_moduleInfo moduleInfo = new Ts_moduleInfo();
    List chList = moduleInfo.getListByPk(module_id);
    Hashtable chMap = new Hashtable();
    if ((chList != null) && (chList.size() > 0)) chMap = (Hashtable)chList.get(0);
    String model = ""; String article_temp = ""; String article_save = "";
    Hashtable paramMap = new Hashtable();
    if (!start.equals("")) paramMap.put("start", start);
    if (!row.equals("")) paramMap.put("row", row);
    if (chMap.get("module_code") != null) model = chMap.get("module_code").toString();
    if (chMap.get("article_temp") != null) article_temp = chMap.get("article_temp").toString();
    if (chMap.get("article_save") != null) article_save = chMap.get("article_save").toString();
    updateArticle(model, article_temp, article_save, paramMap);
  }

  public void updateArticleByGoodsId(String module_id, String info_id, String start, String row) {
    try {
      Ts_moduleInfo moduleInfo = new Ts_moduleInfo();

      List chList = moduleInfo.getListByPk(module_id);
      Hashtable chMap = new Hashtable();
      if ((chList != null) && (chList.size() > 0)) chMap = (Hashtable)chList.get(0);

      String model = ""; String article_temp = ""; String article_save = "";
      Hashtable paramMap = new Hashtable();
      if (!info_id.equals("")) paramMap.put("info_id", info_id);
      if (!start.equals("")) paramMap.put("start", start);
      if (!row.equals("")) paramMap.put("row", row);
      if (chMap.get("module_code") != null) model = chMap.get("module_code").toString();
      if (chMap.get("article_temp") != null) article_temp = chMap.get("article_temp").toString();
      if (chMap.get("article_save") != null) article_save = chMap.get("article_save").toString();
      updateArticle(model, article_temp, article_save, paramMap);
    }
    catch (Exception e) {
      e.printStackTrace();
    }
  }
}